<template>
  <!-- 特征提取 -->
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="数据集名称">
              <j-input placeholder="请输入名称" v-model="queryParam.name"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置 </a-button>
               <a-button @click="handleAdd" type="primary" style="margin-left: 8px" icon="plus" >新增</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: true }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
           <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
          <a-divider type="vertical" />
          <a @click="handleDetail(record)">浏览数据</a>
        </span>
      </a-table>
    </div>
    <data-set-add-modal ref="modalForm" @ok="modalFormOk"></data-set-add-modal> 
    <data-set-detail-modal ref="modalDetailForm"></data-set-detail-modal>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import '@/assets/less/TableExpand.less'
import DataSetAddModal from './DataSetAddModal'
import DataSetDetailModal from './DataSetDetailModal' 
export default {
  name: 'DataSetList',
  mixins: [JeecgListMixin],
  components: {
    DataSetAddModal,
    DataSetDetailModal, 
  },
  data() {
    return {
      description: '数据集生成',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '数据集名称',
          align: 'center',
          dataIndex: 'name',
          width: 200,
        },
        {
          title: '数据集编码',
          align: 'center',
          dataIndex: 'code',
          width: 200,
        },
        {
          title: '类型',
          align: 'center',
          dataIndex: 'dsType',
          width: 150,
        },
        {
          title: '数据量',
          align: 'center',
          dataIndex: 'dataSize',
          width: 200,
        },
          {
          title: '属性数量',
          align: 'center',
          dataIndex: 'fields',
          width: 100,
        }, 
         {
          title: '槽号',
          align: 'center',
          dataIndex: 'slotNo',
          width: 200,
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime',
          width: 200,
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/dataSet/dataSet/list',
        delete: '/dataSet/dataSet/delete',
        deleteBatch: '/userFormula/userFormula/deleteBatch',
        exportXlsUrl: '/userFormula/userFormula/exportXls',
        importExcelUrl: 'userFormula/userFormula/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {},
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'formulaName', text: '公式名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'formulaContent', text: '内容', dictCode: '' })
      fieldList.push({ type: 'date', value: 'modifyDate', text: '修改日期' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      fieldList.push({ type: 'int', value: 'seqNo', text: '序号，用于公式排序', dictCode: '' })
      fieldList.push({ type: 'string', value: 'userId', text: '创建人', dictCode: '' })
      this.superFieldList = fieldList
    },
    modalFormOk(data) { 
      this.loadData(1);
    },
    handleAdd: function () {
      var that = this
      this.$refs.modalForm.add()
    },
    handleDetail(record){
        this.$refs.modalDetailForm.show(record)
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>